import requests

from common.token_util import TokenUtil


class DepartUtil:
    # 封装获取部门id的方法
    @classmethod
    def get_depart_id(cls):
        url = "http://ihrm2-test.itheima.net/api/company/department"
        # TokenUtil.get_token()是调用封装token的方法
        header = {"Content-Type": "application/json", "Authorization": TokenUtil.get_token()}
        body = {"name": "奥特曼警备队", "code": "001"}
        resp = requests.post(url=url, headers=header, json=body)
        depart_id = resp.json().get("data").get("id")
        return depart_id


# if __name__ == '__main__':
#     print(DepartUtil.get_depart_id())